<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #refreshContainer li {
        background-color: #eee;
        margin-bottom: 1px;
        padding: 20px 10px;
    }
    .refreshText {
        position: absolute;
        width: 100%;
        line-height: 50px;
        text-align: center;
        left: 0;
        top: 0;
    }
</style>
<body>
    <p class="refreshText"></p>
    <ul id="refreshContainer">
        <li>111</li>
        <li>222</li>
        <li>333</li>
        <li>444</li>
        <li>555</li>
        <li>111</li>
        <li>222</li>
        <li>333</li>
        <li>444</li>
        <li>555</li>
        <li>111</li>
        <li>222</li>
        <li>333</li>
        <li>444</li>
        <li>555</li>
    </ul>
</body>
<script>
    let flag = ''
    window.onscroll = function () {
        let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
        let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
        if (flag === '' || flag === 'open') {
            if (scrollTop + windowHeight + 100 >= scrollHeight) {
                console.log('触底加载更多')
                // 触发了一次后阀门关闭
                flag = 'close'
            }
        }
        if (scrollTop + windowHeight + 100 < scrollHeight && (flag === '' || flag === 'close')) {
            console.log('开启阀门')
            flag = 'open'
        }
    }
</script>
</html>